#include<iostream>
#define MAX 51

using namespace std;

int stacks[MAX];
int n;
int cont = 0;

int abs(int number) {
   if(number < 0)
      return number * -1;
   return number;
}

void solve() {
   int average = 0;
   int values = 0;
   for(int i=0; i<n; i++)
      average += stacks[i];
   average /= n;
   
   for(int i=0; i<n; i++)
      values += abs(stacks[i]-average);
   
   cout << "Set #" << (++cont) << endl;
   cout << "The minimum number of moves is " << values/2 << "." << endl;
}

int main() {
   cin >> n;
   while(n != 0) {
      for(int i=0; i<n; i++)
         cin >> stacks[i];
      solve();
      cin >> n;
   }
   return 0;
}
